﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" indent="yes"/>

  <xsl:decimal-format name="decimalformat" decimal-separator=',' grouping-separator=' ' />

  <xsl:template match="/root">

    <xsl:variable name="numformat" select="'# ### ##0,00'" />

    <html>
        <head>
          <title></title>
        </head>
        <body>
          <br/>
          <table border="0" bordercolor="#cecece" >
              <tr>
                <td width="400"  border="0">
                  <br />
                  <br />
                  <font size="20">
                    <xsl:text>DEVIS</xsl:text>
                  </font>
                </td>
                <td width="400"  border="0">
			  <br/>
			  <br/>
                  <font size="12">
                    <xsl:value-of select="details/genxml/textbox/txtcompanyname" />
                    <br/>
                    <xsl:value-of select="details/genxml/textbox/txtclientadd1" />
                    <br/>
                    <xsl:value-of select="details/genxml/textbox/txtclientadd2" />
                    <br/>
                    <xsl:value-of select="details/genxml/textbox/txtclientpc" />
                    <br/>
                    <xsl:value-of select="details/genxml/textbox/txtclientadd3" />
                    <br/>
                  </font>
                </td>
              </tr>
            <tr>
              <td border="0">
                <font size="9">
                  <xsl:value-of select="settings/genxml/textbox/txtcompanyaddress"/>
                </font>
              </td>
              <td border="0">
                <font size="10">
                  <br/>
                  <br/>
                  <br/>
                  <br/>
                  <br/>
                  Numéro Devis : <xsl:value-of select="details/genxml/hidden/estimateref" />
                  Date Devis : <xsl:value-of select="substring(details/genxml/textbox/dateestimate,1,10)" />
                  Date de Validité : <xsl:value-of select="substring(details/genxml/textbox/datevalid,1,10)" />
                </font>
              </td>
            </tr>
            <tr>
              <td colspan="2"  border="0">
                <br/>
                <br/>
<xsl:value-of select="details/genxml/textbox/txtnotes" />
              </td>
            </tr>
          </table>
          <table>
            <tr>
              <td width="650" backgroundcolor="#cecece" align="center">
                <font size="8">
                  <b>Description</b>
                </font>
              </td>
              <td width="120" backgroundcolor="#cecece" align="center">
                <font size="8">
                  <b>(<xsl:value-of select="settings/genxml/textbox/txtcurrencysign"/>)</b>
                </font>
              </td>
            </tr>
            <xsl:for-each select="/root/articles/genxml">
              <tr>
                <td width="650">
                  <font size="8">
                    <xsl:value-of select="textbox/txtsummary" />
                  </font>
                </td>
                <td width="120" align="right">
                  <font size="8">
					  <xsl:value-of select="format-number(textbox/txtprice, $numformat,'decimalformat')" />
				  </font>
                </td>
              </tr>

            </xsl:for-each>
            <tr>
              <td colspan="2" backgroundcolor="1" width="770" align="right">
                <font size="8">
                </font>
              </td>
            </tr>
            <xsl:if test="details/genxml/checkbox/chkhidetotal != 'True'">
             <tr>
              <td width="650" align="right">
                <font size="8">Sous-Total (<xsl:value-of select="settings/genxml/textbox/txtcurrencysign"/> HT) :</font>
              </td>
              <td width="120" align="right">
                <font size="8">
					<xsl:value-of select="format-number(details/genxml/hidden/dblsubtotal, $numformat,'decimalformat')" />
				</font>
              </td>
            </tr>
            <tr>
              <td width="650" align="right">
                <font size="8">TVA (<xsl:value-of select="settings/genxml/textbox/txtcurrencysign"/>) :</font>
              </td>
              <td width="120" align="right">
                <font size="8">
					<xsl:value-of select="format-number(details/genxml/hidden/dbltaxtotal, $numformat,'decimalformat')" />
				</font>
              </td>
            </tr>
            <tr>
              <td width="650" align="right">
                <b>Total (<xsl:value-of select="settings/genxml/textbox/txtcurrencysign"/> TTC) :</b>
              </td>
              <td width="120" align="right">
				  <xsl:value-of select="format-number(details/genxml/hidden/dblgrandtotal, $numformat,'decimalformat')" />
			  </td>
            </tr>
            </xsl:if>
          </table>
          <p align="center">
            <font size="5">
              <xsl:value-of select="settings/genxml/textbox/txtpagefooter"/>
            </font>
          </p>
        </body>
      </html>
   
    </xsl:template>

  <xsl:template name="DisplayInfosValue">
    <!--Display Value abd BR  only if not blank-->
    <xsl:param name="DLabel" select="''" />
    <xsl:param name="DValue" select="''" />
    <xsl:if test="$DValue!=''">
      <xsl:value-of select="$DLabel" />
      <xsl:value-of select="$DValue" />
      <br />
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>
